﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;

namespace MaxAlarm.Pages
{
    public class PageManager : DependencyObject
    {
        public static readonly DependencyProperty LoginPageProperty =
            DependencyProperty.Register("LoginPage", typeof (Page), typeof (PageManager), new PropertyMetadata(default(Page)));

        public Page LoginPage
        {
            get { return (Page) GetValue(LoginPageProperty); }
            set { SetValue(LoginPageProperty, value); }
        }

        public static readonly DependencyProperty MainPageProperty =
            DependencyProperty.Register("MainPage", typeof (Page), typeof (PageManager), new PropertyMetadata(default(Page)));

        public Page MainPage
        {
            get { return (Page) GetValue(MainPageProperty); }
            set { SetValue(MainPageProperty, value); }
        }

        public static readonly DependencyProperty SettingsPageProperty =
            DependencyProperty.Register("SettingsPage", typeof (Page), typeof (PageManager), new PropertyMetadata(default(Page)));

        public Page SettingsPage
        {
            get { return (Page) GetValue(SettingsPageProperty); }
            set { SetValue(SettingsPageProperty, value); }
        }

        public static readonly DependencyProperty CurrentPageProperty =
            DependencyProperty.Register("CurrentPage", typeof(Page), typeof(PageManager));

        public Page CurrentPage
        {
            get { return (Page)GetValue(CurrentPageProperty); }
            set { SetValue(CurrentPageProperty, value); }
        }

        private Page _previousPage;

        public void SetPage(Page page)
        {
            _previousPage = CurrentPage;
            CurrentPage = page;
        }

        public void GoToPrevoiusPage()
        {
            if (_previousPage == null)
                return;

            CurrentPage = _previousPage;
            _previousPage = null;
        }
    }
}
